package com.whosly.spring.cloud.components.starter.sentry.configure.data;

import com.sun.org.apache.xpath.internal.operations.Bool;
import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;

import java.time.Duration;

/**
 * Configuration properties for Sentry.
 *
 * <code>
      # 是否开启。true 开启， false 关闭
      sentry.spring.enable = true
      sentry.spring.dns = http://211dc184a16f4e09830c5a3111812bc3@localhost:9000/2
      sentry.spring.sampleRate = 0.2
      sentry.spring.tracesSampleRate = 0.2
      sentry.spring.debug = true
      sentry.spring.release = my-project-name@2.3.12
      sentry.spring.environment = local
      sentry.spring.shutdownTimeout = 2000
      sentry.spring.flushTimeoutMillis = 15000
      sentry.spring.connectionTimeoutMillis = 5000
      sentry.spring.readTimeoutMillis = 5000
 * </code>
 */
@ConfigurationProperties(prefix = "sentry")
public class SentryProperties {

    /**
     * Whether to enable sentry support.
     */
    @Getter
    @Setter
    private boolean enable = true;

    /**
     * The DSN tells the SDK where to send the events to. If this value is not provided, the SDK will
     * just not send any events.
     */
    @Getter
    @Setter
    private String dsn;

    /**
     * Configures the sample rate as a percentage of events to be sent in the range of 0.0 to 1.0. if
     * 1.0 is set it means that 100% of events are sent. If set to 0.1 only 10% of events will be
     * sent. Events are picked randomly. Default is null (disabled)
     */
    @Getter
    @Setter
    private Double sampleRate;

    /**
     * Configures the sample rate as a percentage of transactions to be sent in the range of 0.0 to
     * 1.0. if 1.0 is set it means that 100% of transactions are sent. If set to 0.1 only 10% of
     * transactions will be sent. Transactions are picked randomly. Default is null (disabled)
     */
    @Getter
    @Setter
    private Double tracesSampleRate;

    /**
     * Turns debug mode on or off. If debug is enabled SDK will attempt to print out useful debugging
     * information if something goes wrong. Default is disabled.
     */
    @Getter
    @Setter
    private Boolean debug;

    /**
     * Sets the release. SDK will try to automatically configure a release out of the box
     */
    @Getter
    @Setter
    private String release;

    /**
     * Sets the environment. This string is freeform and not set by default. A release can be
     * associated with more than one environment to separate them in the UI Think staging vs prod or
     * similar.
     */
    @Getter
    @Setter
    private String environment;

    /**
     * Controls how many seconds to wait before shutting down. Sentry SDKs send events from a
     * background queue and this queue is given a certain amount to drain pending events Default is
     * 2000 = 2s
     */
    @Getter
    @Setter
    private Long shutdownTimeout;
//    private Duration readTimeoutMillis = Duration.ofMillis(5000L);

    /**
     * Controls how many seconds to wait before flushing down. Sentry SDKs cache events from a
     * background queue and this queue is given a certain amount to drain pending events Default is
     * 15000 = 15s
     */
    @Getter
    @Setter
    private Long flushTimeoutMillis;

    /**
     * connection timeout in milliseconds.
     */
    @Getter
    @Setter
    private int connectionTimeoutMillis = 5000;

    /**
     * read timeout in milliseconds
     */
    @Getter
    @Setter
    private int readTimeoutMillis = 5000;

    /**
     * Sets the max breadcrumbs Default is 100
     */
    @Getter
    @Setter
    private int maxBreadcrumbs = 100;

    /**
     * Enables loading additional options from external locations like {@code sentry.properties} file
     * or environment variables, system properties.
     */
    @Getter
    @Setter
    private Boolean enableExternalConfiguration;


    /** The cache dir. path for caching offline events */
    @Getter
    @Setter
    private String cacheDirPath;


    /**
     * 应用内包含， 逗号分割
     *
     * com.whosly.spring.cloud, org.spring
     */
    @Getter
    @Setter
    private String inAppIncludes;

    /**
     * 应用内排除， 逗号分割
     *
     * com.whosly.spring.cloud, org.spring
     */
    @Getter
    @Setter
    private String inAppExcludes;

    /**
     * 忽略类型的异常， 逗号分割
     *
     * java.lang.RuntimeException,java.lang.IllegalStateException
     */
    @Getter
    @Setter
    private String ignoredExceptionsForType;

    //#  tags.first_tag: first-tag-value
//#  tags.second_tag: second-tag-value

}
